package com.knight.concurrent.chapter11;

import java.util.function.Consumer;

/**
 * @Description:
 * @author: knight
 * @Date: 2019-03-11 20:06
 */
public class ObServerClient {

    public static void main(String[] args) {
        Subject subject = new Subject();

        new BinaryObServer(subject);
        subject.setState(10);
        System.out.println("============================");
        subject.setState(15);
        System.out.println("============================");
        subject.setState(15);
        System.out.println("============================");
        subject.setState(20);

        // consumer
        test("abc",System.out::println);

    }


    public static void  test(String test, Consumer consumer){
        new Thread(()->{
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

            consumer.accept(test);
        }).start();
    }


}
